package com.airport.schedule.genetic;

import com.airport.schedule.ScheduleEvaluator;
import com.airport.schedule.ScheduleSolution;
import org.jgap.CachedFitnessFunction;
import org.jgap.IChromosome;

class ScheduleFitnessFunction extends CachedFitnessFunction {

    private GeneticScheduler scheduler;

    public ScheduleFitnessFunction(GeneticScheduler scheduler) {
        this.scheduler = scheduler;
    }

    @Override
    protected double evaluate(IChromosome iChromosome) {
        ScheduleSolution solution = scheduler.parse(iChromosome);
        return ScheduleEvaluator.evaluateForGenetic(solution);
    }

}
